import { defineStore } from 'pinia'
import axios from 'axios'

export const useMatchIdStore = defineStore('matchId', {
    actions: {
        setMatchId(matchId) {
            this.matchId = matchId 
        },
        async setMatchName(id){                        
            try{
                const response = await axios.get(`http://back1.idcfengye.com:15173/competition/match/${id}`)
                localStorage.setItem('match', JSON.stringify(response.data.match));
            }catch(error){
                console.log(error);
            }
        }
    },
    state: () => ({
        matchId: localStorage.getItem('matchId') || null,
        token: localStorage.getItem('userToken') || null
    })
})